const path = require("path");
const resolve = function(dir) {
  return path.join(__dirname, dir);
};

module.exports = {
  publicPath: process.env.NODE_ENV === "production" ? "/message/" : "/",
  outputDir: "dist",
  assetsDir: "static",
  lintOnSave: false, // 是否开启eslint保存检测
  productionSourceMap: false, // 是否在构建生产包时生成sourceMap
  chainWebpack: (config) => {
    config.resolve.alias
      .set("@", resolve("src"))
      .set("views", resolve("src/views"));
    config.optimization.runtimeChunk("single");
  },
  devServer: {
    host: "localhost",
    port: "8080",
    hot: true,
    open: false,
    overlay: {
      warning: false,
      error: true,
    },
    proxy: {
      // 短信
      "/msg/": {
        target: process.env.VUE_APP_BASE_API, // 需要使用user-agent对应dev、test
        changeOrigin: true,
        // pathRewrite: {
        //   ["^" + process.env.VUE_APP_BASE_API]: ""
        // }
      },
      // 独立系统
      "/independent-system/": {
        target: process.env.VUE_APP_BASE_API, // 需要使用user-agent对应dev、test
        changeOrigin: true,
      },
    },
  },
};
